import json


class ResponseJson:
    """
    响应json格式
    """

    def __init__(self, code=200, msg='success', data=None):
        self.code = code
        self.msg = msg
        self.data = data

    def to_json(self):
        return json.dumps(self.__dict__, ensure_ascii=False)

    @classmethod
    def to_dict(cls, obj):
        return obj.__dict__
